var editSec;
var editType;

$(function() {
	var opentParent = frame.window.getOpenParent();
	editType = opentParent.editType;
	if (editType == "edit") {
		editSec = opentParent.$('#dg').datagrid("getSelected");
		$("#ff").form("load", editSec);
	} else {
		$("#secId").textbox('readonly',false);
		$("#ticker").textbox('readonly',false);
	}
});

function click_back(){
	frame.window.closeWindow();
}

function click_save(){
	var a=$("#ff").form('validate');
	if(!a){
		return;
	}
	
	editSec = $("#ff").form("getData");
	editSec.editType = editType;
	$.post("./save.json", editSec, function(data) {
		if (data.sucesse == true) {
			frame.window.getOpenParent().$('#dg').datagrid("reload");
			frame.window.closeWindow();
		}
	});
}

function click_delete(){
	$.messager.confirm('确认', '您确认想要删除吗？', function(r) {
		if (r) {
			deleteSecurity();
		}
	});
}

function deleteSecurity(){
	$.post("./delete.json", editSec, function(data) {
		if (data.sucesse == true) {
			frame.window.getOpenParent().$('#dg').datagrid("reload");
			frame.window.closeWindow();
		}
	});
}
